﻿/*
 * Created by SharpDevelop.
 * User: notmmao
 * Date: 2008-3-29
 * Time: 9:10
 * 
 */

using System;
using System.Drawing;

namespace Deebug.Games.ShortBoom
{
	/// <summary>
	/// Description of ball.
	/// </summary>
	public class Ball:Sprite
	{
		public Player Owner;
		public Ball(Gate word,Bitmap frame,Player player)
			:this(word,-1000,-1000,frame,player)
		{
			
		}
		public Ball(Gate word,int x,int y,Bitmap frame,Player player)
			:base( word, x, y, frame)
		{
			//只能为垂直运动
			this.Vector.Y = -1;
			this.Speed = 20;
			this.Visible = false;
			Owner = player;
		}
		
		
		public override void UpDate(float gameTime, float elapsedTime)
		{
//			if(this.Visible){
//				if(this.Location.Y> -this.Height){
//					base.UpDate();
//					return;
//				}else{
//					this.Visible = false;
//				}
//			}else{
//				if(KeyBoard.Space){
//					this.Location = this.Owner.Location;
//					this.Visible = true;
//					base.UpDate();
//					return ;
//				}
//			}
//
			//是否走出上边界
			
			if(this.Location.Y< -this.Height)
				this.Visible = false;

			//可以发射子弹-条件是前一个子弹消失
			if(!Visible){
				if(KeyBoard.Space){
					this.Location = this.Owner.Location;
					this.Visible = true;
					base.UpDate(gameTime,elapsedTime);
				}
			}
			else{
				base.UpDate(gameTime,elapsedTime);
			}
		}
	}
}
